#region Copyright

// // ======================================================
// //     Copyright (c) 2011 Toulr All rights reserved.
// //    
// //     The use and distribution terms for this software are contained in the file
// //     named license.txt, which can be found in the root of this distribution.
// //     By using this software in any fashion, you are agreeing to be bound by the
// //     terms of this license.
// //    
// //     You must not remove this notice, or any other, from this software.
// // ======================================================

#endregion

#region Using Namespaces

using System;
using System.IO;
using log4net;
using log4net.Config;
using Toulr.Util.Logging.Factories;

#endregion

namespace Toulr.Util.Logging.log4netIntegration
{

    #region

    #endregion

    public class ExtendedLog4NetFactory : AbstractExtendedLoggerFactory
    {
        public ExtendedLog4NetFactory() : this("log4net.config")
        {
        }

        public ExtendedLog4NetFactory(String configFile)
        {
            FileInfo file = GetConfigFile(configFile);
            XmlConfigurator.ConfigureAndWatch(file);
        }

        /// <summary>
        ///   Creates a new extended logger.
        /// </summary>
        public override IExtendedLogger Create(string name)
        {
            ILog log = LogManager.GetLogger(name);
            return new ExtendedLog4netLogger(log, this);
        }

        /// <summary>
        ///   Creates a new extended logger.
        /// </summary>
        public override IExtendedLogger Create(string name, LoggerLevel level)
        {
            throw new NotSupportedException(
                "Logger levels cannot be set at runtime. Please review your configuration file.");
        }
    }
}